(function($) {
    $.fn.time_yxd = function(options) {
        var defaults = {};
        var settings = $.extend({},
        defaults, options);
        return this.each(function() {
            var ele = $(this);
            var ele_hei = ele.outerHeight();
            var ele_lef = ele.position().left;
            ele_hei += 15;
            //$(ele).wrap("<div class='time_pick'>");
            //var ele_par = $(this).parent("div");
            //ele_par.append("<div class='timepicker_wrap'><div class='arrow_top'></div><div class='time'><div class='prev'></div><div class='ti_tx'></div><div class='next'></div></div><div class='mins'><div class='prev'></div><div class='mi_tx'></div><div class='next'></div></div><div class='meridian'><div class='prev'></div><div class='mer_tx'></div><div class='next'></div></div></div>");
            var ele_next = $(this).next("div");
            var ele_next_all_child = ele_next.find("ul");
            ele_next.css({
                "top": ele_hei + "px",
                "left": ele_lef + "px"
            });
            $(document).on("click",function(event) {
                if (!$(event.target).is(ele_next)) {
                    if (!$(event.target).is(ele)) {
                        if (!$(event.target).is(ele_next) && !$(event.target).is(ele_next_all_child)) {
                            ele_next.fadeOut()
                        }
                    } else {
                       
                        ele_next.fadeIn();
                    }
                }
            });
            
            $(".time_box_wrap ul li").click(function(e){
            	
            	$(this).parents("div").prev("input").val($(this).text());
            	//e.stopPropagation();
            });
         
            
            
        })
    }
} (jQuery));